package com.fzshang.shopping.commen.serviceImpl;

import com.fzshang.shopping.commen.bean.Classification;
import com.fzshang.shopping.commen.bean.ShoppingOrder;
import com.fzshang.shopping.commen.bean.layuiBean.ResultPage;
import com.fzshang.shopping.commen.bean.layuiBean.VoPage;
import com.fzshang.shopping.commen.mapper.ShoppingOrderMapper;
import com.fzshang.shopping.commen.service.ShoppingOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 冯政尚
 * @since 2020-03-28
 */
@Service
public class ShoppingOrderServiceImpl extends ServiceImpl<ShoppingOrderMapper, ShoppingOrder> implements ShoppingOrderService {

    @Override
    public List<ShoppingOrder> selectOrderDesc(String openid) {
        Map map = new HashMap();
        map.put("openid",openid);
        return baseMapper.selectOrderDesc(map);
    }

    @Override
    public List<ShoppingOrder> selectDaiFuKuanOrderDesc(String openid) {
        Map map = new HashMap();
        map.put("openid",openid);
        return baseMapper.selectDaiFuKuanOrderDesc(map);
    }

    @Override
    public List<ShoppingOrder> selectDaiFaHuoOrderDesc(String openid) {
        Map map = new HashMap();
        map.put("openid",openid);
        return baseMapper.selectDaiFaHuoOrderDesc(map);
    }

    @Override
    public List<ShoppingOrder> selectDaiShouHuoOrderDesc(String openid) {
        Map map = new HashMap();
        map.put("openid",openid);
        return baseMapper.selectDaiShouHuoOrderDesc(map);
    }

    @Override
    public List<ShoppingOrder> selectTuiSHouOrderDesc(String openid) {
        Map map = new HashMap();
        map.put("openid",openid);
        return baseMapper.selectTuiSHouOrderDesc(map);
    }
    /**
     * @param voPage
     * @return 后台查询
     */
    @Override
    public ResultPage<ShoppingOrder> selectMyPage(VoPage voPage, ShoppingOrder shoppingOrder) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("page", (voPage.getPage() - 1) * voPage.getLimit());
        paramMap.put("limit", voPage.getLimit());
        paramMap.put("oddNumber", shoppingOrder.getOddNumber());
        paramMap.put("phone", shoppingOrder.getPhone());
        paramMap.put("state", shoppingOrder.getState());
        paramMap.put("type", shoppingOrder.getType());
        List<ShoppingOrder> list = baseMapper.selectMyPage(paramMap);
        Integer count = baseMapper.countMyPage(paramMap);
        ResultPage<ShoppingOrder> resultPage = new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);
        return resultPage;
    }
}
